str1 = "123456"
# str1 = "1.123" 不能转
# str1 = "11aa"
float1 = 1.23
boolean1 = True
boolean2 = False

# 字符串转换成整数
int1 = int(str1)
print(type(int1),int1)
# 浮点数转整数
int2 = int(float1)
print(type(int2),int2)
# 布尔转整数
int3 = int(boolean1)
print(type(int3),int3)
int4 = int(boolean2)
print(type(int4),int4)

# 字符串转浮点数
float2 = float(str1)
print(type(float2),float2)
# 整数转浮点数
float3 = float(int1)
print(type(float3),float3)

# 应用字符串拼接

# 整数转字符串
string1 = str(int1)
print(int1,type(int1),type(string1),string1)
# 浮点数转字符串
string2 = str(float1)
print(float1,type(float1),type(string2),string2)

# 布尔转字符串
string3 = str(boolean1)
print(boolean1,type(boolean1),type(string3),string3)
string4 = str(boolean2)
print(boolean2,type(boolean2),type(string4),string4)

# 整数转布尔  非零的都是True
boolean3 = bool(int1)
print(int1,type(int1),type(boolean3),boolean3)
int0 = 0
boolean4 = bool(int0)
print(int0,type(int0),type(boolean4),boolean4)


msg = "转账两百万"
# msg = " "      # True
# msg = ""       # False
print(type(msg),msg)
msgBool = bool(msg)
print(type(msgBool),msgBool)


list1 = ['admin','zhangsan']
# list1 = ['']  # True
# list1 = []    # False
print(type(list1),list1)
listBool = bool(list1)
print(type(listBool),listBool)



# 元组
yuanzu = ('admin','zhangsan')
yzBool = bool(yuanzu)
print(yuanzu,type(yuanzu),type(yzBool),yzBool)

# 字典
dict1 = {"username":"admin"}
# dict1 = {}  # False
dictBool = bool(dict1)
print(dict1,type(dict1),type(dictBool),dictBool)

